<?php
use Doctrine\ORM\Tools\Setup;

require_once "Doctrine/ORM/Tools/Setup.php";

$directory = __DIR__."/../lib/orm.doctrine/";

Setup::registerAutoloadDirectory($directory);

$isDevMode = true;
//$config = Setup::createXMLMetadataConfiguration(array(__DIR__."/config/xml"), $isDevMode);
$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__."/entity"), $isDevMode);

// database configuration parameters
$data = fopen(__DIR__."/../config/application.properties", "r");

$props = array();

while (!feof($data)) {
	$lineString = fgets($data);
	$keyPair = explode("=",trim($lineString));
	$props[$keyPair[0]] = $keyPair[1];
}

fclose($data);

$conn = array(
    'driver' => $props["mobi.db_driver"],
    'dbname' => $props["mobi.db_name"],
    'user' => $props["mobi.db_username"],
    'password' => $props["mobi.db_password"],
    'host' => $props["mobi.db_host"],
);
// obtaining the entity manager
$entityManager = \Doctrine\ORM\EntityManager::create($conn, $config);